<!-- Author: Mary Llenos --> 
<!-- Last Modified: 9 Sep 2012 --> 
<!-- Page where user can either log in or create new account--> 
<?php
	session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Assn3_template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>www.onestopjcu template</title>

<!-- InstanceEndEditable -->

	<link href="Assn3_CSS.css" rel="stylesheet" type="text/css" />
	<link type="text/css" href="New folder/menu.css" rel="stylesheet" />
    <script type="text/javascript" src="New folder/jquery.js"></script>
    <script type="text/javascript" src="New folder/menu.js"></script>
    <script>
document.write('<div style="display:none;"><a href="http://apycom.com/">jQuery Menu by Apycom</a></div>');
</script>
</head>

<body>
<div class="container" id="top">

<div class="heads"><!-- heads -->
<div class="welcome">
<table>
<tr>
<td>
<?php  echo $_SESSION['msg2']; ?>
<a href="register.php"><?php  echo $_SESSION['msg1']; ?></a>
</td>
</tr>
</table>
</div>
</div>

<div id="menu">
  
  <ul class="menu1">
  		<li><a href="home.php" class="parent"><span>Home</span></a></li>
	
		<li><a href="member.php" class="parent"><span>Member</span></a>
			<div><ul>
    			<li><a href="member.php"><span>Member</span></a></li>            
				<li><a href="register.php"><span><?php  echo $_SESSION['msgMember']; ?></span></a></li>
    		
    		</ul></div>
		</li>           
        	
		<li><a href="Accommodation.php" class="parent"><span>Accommodation</span></a>
			<div><ul>           
				<li><a href="accommodation.php"><span>Search Room</span></a></li>
        		<li><a href="Accom_newpost.php"><span>Post New Advitisement</span></a></li>
            	<li><a href="viewpost.php"><span>View Your Posts</span></a></li>
       		
    		</ul></div>
		</li>	


		<li><a href="shopping.php" class="parent"><span>Selling Books</span></a>
			<div><ul>           
				<li><a href="shopping.php"><span>Browse Books</span></a></li>
           		<li><a href="shopping_newpost.php"><span>Post New Books</span></a></li>
             	<li><a href="view_cart.php"><span>View Your Carts</span></a></li>
       		   		
    		</ul></div>
	</li>



		<li><a href="announcement.php" class="parent"><span>Announcement</span></a>
			<div><ul>
    			<li><a href="announcement.php"><span>Announcement</span></a></li>           
        		<li><a href="new_announce.php"><span>Post New Announcement</span></a></li> 
            	<li><a href="viewmypost.php"><span>View Your Posts</span></a></li> 
                
    		</ul></div>
	</li>


        <li class="last"><a href="aboutus.php"><span>About us</span></a>
        	<div><ul>
            	<li><a href="feedback.php"><span>Feedback</span></a></li>
            </ul></div>
        
        </li>


<!-- InstanceBeginEditable name="phplogin" -->

<!-- InstanceEndEditable -->


</div><!-- menu -->


<!-- InstanceBeginEditable name="main" -->
<div class="main1">
<?php 
if ($_SESSION['msg1'] == "Logout") {
	session_destroy();
	header("Location: home.php");
} 
?>



<div style="width:497px; min-height: 358px; float:left; border-left: solid 1px #BCBCBC; border-right: solid 1px #BCBCBC;">
<div style="width:494px; min-height: 358px; float:left; margin:3px; background-color: #F0F0F0;">

<h3 style="padding-left:20px; font-family: Arial, Helvetica, sans-serif; margin-bottom:20px;">Register</h3>

<form name=formOne action="db_register.php" method="post" onSubmit="return confirmAction(this)">
    <table width="500" border="0">
    <tr>
    <td align="center" style="color:#F00" colspan="2"><?php if (isset($_SESSION['msg3'])) { 
	echo $_SESSION['msg3'];
unset($_SESSION['msg3']); }
 ?>
    </td>
    </tr>
      <tr >
        <td>Name</td>
        <td><input type="text" name="fname" SIZE="20" MAXLENGTH="20"/> <input type="text" name="lname" SIZE="20" MAXLENGTH="20"/></td>
      <tr>
        <td>Gender</td>
        <td><select name="gender">
        <option value="female">female</option>
        <option value="male">male</option>
        </select></td>
      </tr>
      <tr>
        <td>Nationality</td>
        <td><select name="nationality">
        <option value="Chinese">Chinese</option>
        <option value="Indian">Indian</option>
        <option value="Myanmar">Myanmar</option>
        <option value="Vietnamese">Vietnamese</option>
        </select></td>
      </tr>
      <tr>
        <td>Phone Number</td>
        <td><input id="phone" type="text" name="phone" SIZE="25" MAXLENGTH="20" onchange="phonevalidate()" onkeyup="nospaces(this)"/></td>
        </tr>
        <tr>
        <td></td>
        <td><label style="color: #F00;" id="errorPhone"></label>
        </td>
      </tr>
      <tr>
        <td>Email Address</td>
        <td><input id="email" type="text" name="email" SIZE="25" MAXLENGTH="20" onchange="validate()"/></td>
        </tr>
        <tr>
        <td></td>
        <td>
        <label style="color: #F00;" id="errorEmailAddress"></label></td>
      </tr>
     <tr>
        <td>Password</td>
        <td><input id="pword1" type="password" name="pword" SIZE="20" MAXLENGTH="20" onchange="pwvalidate()" /><label style="color: #F00;" id="errorPassword" ></label></td>
      </tr>
      <tr>
        <td>Re-type Password</td>
        <td><input id="pword2" type="password" name="password" SIZE="20" MAXLENGTH="20"/></td>
      </tr>
      <tr >
        <td colspan="2">&nbsp;</td>
        </tr>
      <tr >
        <td colspan="2" align="center">
        <input type="button" name="Cancel" value="Cancel" onClick="cancel();">
        <input type="submit" name="signup" value="Register" /></td>
      </tr>
    </table>
<script type="text/javascript">
function validate() {
	var str = document.getElementById('email').value;
	if ( document.getElementById('email').value.length == 0 || str.indexOf("@jcu.com")<0 ) {
		document.getElementById('errorEmailAddress').innerHTML = " - invalid email address (Only accepts @jcu.com email)";
		document.formOne.signup.disabled=true;
		return false;}
	else {
		document.formOne.signup.disabled=false;
		document.getElementById('errorEmailAddress').innerHTML = "";
		}
	}
	function phonevalidate() {
			
	if ( document.getElementById('phone').value.length != 8 || isNaN(document.getElementById('phone').value)) {
		document.getElementById('errorPhone').innerHTML = " - invalid SG phone number (eg.99889988)";
		document.formOne.signup.disabled=true;
		return false;}
	else {
		document.formOne.signup.disabled=false;
		document.getElementById('errorPhone').innerHTML = "";
		}
	}

function nospaces(t){
	if(t.value.match(/\s/g)){
		alert('Sorry, you are not allowed to enter any spaces');
		t.value=t.value.replace(/\s/g,'');
	}
}
function pwvalidate() {
			
	if ( document.getElementById('pword1').value.length <= 7) {
		document.getElementById('errorPassword').innerHTML = " - min length: 8 chars";
		document.formOne.signup.disabled=true;
		return false;}
	else {
		document.formOne.signup.disabled=false;
		document.getElementById('errorPassword').innerHTML = "";
		}
	}

function cancel()
{

	var r=confirm("Are you sure you want to cancel your registration?");
	if (r==true)
 	 {
 		 window.location.href = "home.php";
 	 }

}
function confirmAction(form) {
	
	str=form.email.value;
        
  if (form.fname.value == "") {
    alert( "Please fill-in your first name." );
    form.fname.focus();
    return false ;
  }
  if (form.lname.value == "") {
    alert( "Please fill-in your last name." );
    form.lname.focus();
    return false ;
  }
    if (form.phone.value == "") {
    alert( "Please fill-in your phone number." );
    form.phone.focus();
    return false ;
  }
  if (form.email.value == "" || str.indexOf("@jcu.com")<0) {
    alert( "Please fill-in your email add correctly. Only jcu emails are accepted (@jcu.com)!" );
    form.email.focus();
    return false ;
  }

  if (form.pword.value == "") {
    alert( "Please fill-in your password." );
    form.pword.focus();
    return false ;
  }
  if (form.password.value == "") {
    alert( "Please re-type your password again" );
    form.password.focus();
    return false ;
  }

  if (form.pword.value != form.password.value) {
    alert( "You have re-typed a different password.  Please re-type again." );
    form.password.focus();
    return false ;
  }
 
  return confirm("Are you certain of the information you have filled-in?")
  }
      

</script>
    </form>
</div>
</div>


<div style="width:496px; height: 358px; float:left; border-right: solid 1px #BCBCBC;">
<div style="width:496px; height: 358px; float:left; margin:3px; background-color: #F0F0F0;">
<h3 style="padding-left:20px; font-family: Arial, Helvetica, sans-serif; margin-bottom:20px;">Log In</h3>
<?php 
if (!isset($_SESSION['msg'])) {
	$_SESSION['msg'] = "";
}
?>
<form name="formTwo" method="post" action="validate.php" onsubmit="return checkform(this);">
<table align="center">
<tr>
<td colspan="2">Note: Please use your email address as your username to login.
</td>
</tr>
<tr>
<td colspan="2" style="color:#F00" align="center">
<?php  echo $_SESSION['msg']; ?>
</td>
</tr>
<tr>
<td align="right">
Username</td><td>: <input name="myusername" type="text" id="myusername" /></td>
</tr>
<tr>
<td align="right">Password</td><td>: <input name="mypassword" type="password" id="mypassword" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="button" name="Cancel" value="Cancel" onClick="cancel();">
<input type="submit" name="Submit" value="Login"/></td>
<script type="text/javascript">

function cancel()
{

	var r=confirm("Are you sure you want to cancel Log-in session?");
	if (r==true)
  	{
  		 <?php  unset($_SESSION['msg']); ?>
 		 window.location.href = "home.php";
  	}

}
function checkform ( form )
{

  if (form.myusername.value == "") {
    alert( "Please enter your username." );
    form.myusername.focus();
    return false ;
  }
  if (form.mypassword.value == "") {
    alert( "Please enter your password." );
    form.mypassword.focus();
    return false ;
  }
 
  return true ;
}
</script>


</table></form>
</form>

</div>

</div><!-- main -->
<!-- InstanceEndEditable -->


<div class="footer"> 
<div style="margin-left:10px; float:left; font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:12px; color:#FFF; width:430px; height:12px; margin-top:16px;">Copyright &copy; 2012 www.onestopjcu.com
</div>

<div style="margin-left:50px; float:left; font-family:Arial, Helvetica,sans-serif; font-weight:bold; font-size:11px; width:100px; height:12px; margin-top:16px;"><a href="#top" style="color:#FFF; text-decoration: none;">Return to Top</a>
</div>

<ul>
<li><a href="feedback.php">Feedback</a></li>
<li><a href="FAQ.php">FAQ</a></li>
<li><a href="aboutus.php" style="margin-right:24px;">About Us</a></li>
<li><a href="aboutus.php" style="margin-right:24px;">Contact Us</a></li>
</ul>




</div><!-- footer -->
</div><!-- container -->
</body>
<!-- InstanceEnd --></html>

